home *** CD-ROM | disk | FTP | other *** search
/ Resource Library: Multimedia / Resource Library: Multimedia.iso / hypercrd / xcmds / shwdlg16.hqx / ShowDialog XCMD 1.6 / card_5437.txt < prev    next >
Text File  |  1989-05-10  |  10KB  |  253 lines

  1. -- card: 5437 from stack: in.6
  2. -- bmap block id: 0
  3. -- flags: 0000
  4. -- background id: 3411
  5. -- name: Type 2 XCMD
  6.  
  7.  
  8. -- part 1 (button)
  9. -- low flags: 80
  10. -- high flags: A003
  11. -- rect: left=287 top=66 right=89 bottom=403
  12. -- title width / last selected line: 0
  13. -- icon id / first selected line: 0 / 0
  14. -- text alignment: 1
  15. -- font id: 0
  16. -- text size: 12
  17. -- style flags: 0
  18. -- line height: 16
  19. -- part name: "Change" Dialog
  20. ----- HyperTalk script -----
  21. on mouseUp
  22.   ShowDialog 2,4740,"Find What:","Change To:","Your string goes here."
  23.   if the result is empty then
  24.     put "You clicked the ΓÇ£CancelΓÇ¥ button." into bg fld "theResult"
  25.   else
  26.     put the result into temp
  27.     if line 1 of temp is empty then
  28.       put "String 1 was:  empty" & return into bg fld "theResult"
  29.     else put "String 1 was:" && line 1 of temp & return into bg fld "theResult"
  30.     if line 2 of temp is empty then
  31.       put "String 2 was:  empty" after bg fld "theResult"
  32.     else put "String 2 was:" && line 2 of temp after bg fld "theResult"
  33.   end if
  34. end mouseUp
  35.  
  36.  
  37.  
  38. -- part 2 (button)
  39. -- low flags: 80
  40. -- high flags: A003
  41. -- rect: left=232 top=98 right=121 bottom=456
  42. -- title width / last selected line: 0
  43. -- icon id / first selected line: 0 / 0
  44. -- text alignment: 1
  45. -- font id: 0
  46. -- text size: 12
  47. -- style flags: 0
  48. -- line height: 16
  49. -- part name: "Change" Dialog with Checkbox
  50. ----- HyperTalk script -----
  51. on mouseUp
  52.   put TRUE into checked --checkbox initially checked
  53.   ShowDialog 2,4744,"Find What:","Change To:", "Your string goes here.",checked
  54.   if the result is empty then
  55.     put "You clicked the ΓÇ£CancelΓÇ¥ button." into bg fld "theResult"
  56.   else
  57.     put the result into temp
  58.     if item 1 of line 1 of temp = "TRUE" then
  59.       put "Checked" into checked
  60.     else put "Unchecked" into checked
  61.     put "The checkbox was:" && checked & return into bg fld "theResult"
  62.     if line 2 of temp is empty then
  63.       put "String 1 was:  empty" & return after bg fld "theResult"
  64.     else put "String 1 was:" && line 2 of temp & return after bg fld "theResult"
  65.     if line 3 of temp is empty then
  66.       put "String 2 was:  empty" after bg fld "theResult"
  67.     else put "String 2 was:" && line 3 of temp after bg fld "theResult"
  68.   end if
  69. end mouseUp
  70.  
  71.  
  72.  
  73. -- part 3 (button)
  74. -- low flags: 80
  75. -- high flags: A003
  76. -- rect: left=294 top=130 right=153 bottom=393
  77. -- title width / last selected line: 0
  78. -- icon id / first selected line: 0 / 0
  79. -- text alignment: 1
  80. -- font id: 0
  81. -- text size: 12
  82. -- style flags: 0
  83. -- line height: 16
  84. -- part name: "Ask" Dialog
  85. ----- HyperTalk script -----
  86. on mouseUp
  87.   ShowDialog 2,4741,"Type something in this box:","","This is the something!"
  88.   if the result is empty then
  89.     put "You clicked the ΓÇ£CancelΓÇ¥ button." into bg fld "theResult"
  90.   else put the result into bg fld "theResult"
  91. end mouseUp
  92.  
  93.  
  94.  
  95. -- part 4 (button)
  96. -- low flags: 80
  97. -- high flags: A003
  98. -- rect: left=258 top=162 right=185 bottom=425
  99. -- title width / last selected line: 0
  100. -- icon id / first selected line: 0 / 0
  101. -- text alignment: 1
  102. -- font id: 0
  103. -- text size: 12
  104. -- style flags: 0
  105. -- line height: 16
  106. -- part name: "Ask" Dialog/no prompt
  107. ----- HyperTalk script -----
  108. on mouseUp
  109.   ShowDialog 2,4741,"Type something in this box:","",""
  110.   if the result is empty then
  111.     put "You clicked the ΓÇ£CancelΓÇ¥ button or left the field empty." into bg fld "theResult"
  112.   else put the result into bg fld "theResult"
  113. end mouseUp
  114.  
  115.  
  116.  
  117. -- part 6 (button)
  118. -- low flags: 80
  119. -- high flags: A003
  120. -- rect: left=256 top=194 right=217 bottom=427
  121. -- title width / last selected line: 0
  122. -- icon id / first selected line: 0 / 0
  123. -- text alignment: 1
  124. -- font id: 0
  125. -- text size: 12
  126. -- style flags: 0
  127. -- line height: 16
  128. -- part name: Dialog with Many Fields
  129. ----- HyperTalk script -----
  130. on mouseUp
  131.   put "TRUE,FALSE,TRUE" into bools
  132.   ShowDialog 2,4347,"Fill in your address information:","","",bools
  133.   if the result is empty then exit mouseUp
  134.   put the result into info
  135.   put line 1 of info & return & line 2 of info && line 3 of info & return & line 4 of info & return & line 5 of info & "," && line 6 of info && line 7 of info into bg fld "theResult"
  136. end mouseUp
  137.  
  138.  
  139.  
  140. -- part 7 (button)
  141. -- low flags: 80
  142. -- high flags: 0000
  143. -- rect: left=11 top=4 right=64 bottom=78
  144. -- title width / last selected line: 0
  145. -- icon id / first selected line: 529 / 529
  146. -- text alignment: 1
  147. -- font id: 0
  148. -- text size: 12
  149. -- style flags: 0
  150. -- line height: 16
  151. -- part name: 
  152.  
  153.  
  154. -- part 8 (button)
  155. -- low flags: 00
  156. -- high flags: 0000
  157. -- rect: left=11 top=4 right=64 bottom=78
  158. -- title width / last selected line: 0
  159. -- icon id / first selected line: 529 / 529
  160. -- text alignment: 1
  161. -- font id: 0
  162. -- text size: 12
  163. -- style flags: 0
  164. -- line height: 16
  165. -- part name: SD
  166.  
  167.  
  168. -- part contents for background part 21
  169. ----- text -----
  170. ShowDialog XCMD Type 2
  171.  
  172. -- part contents for background part 30
  173. ----- text -----
  174. 14
  175.  
  176. -- part contents for background part 18
  177. ----- text -----
  178. The HyperCard "ask" dialog is functional for providing information to the user and then retrieving information from the user but is not a pretty sight.  
  179. (Where's the icon?)  Additionally, it would be handy to have an "ask" dialog that could return more than one string, for, say, a search and replace dialog box, ├á la any word processor, or a data entry dialog, and a number of check boxes so you could perform some BOOLEAN operations.
  180.  
  181. ShowDialog XCMD Type 2 provides a mechanism for the display of such interactive dialog boxes.
  182.  
  183.            •••••••••••••••••
  184. If you've been using versions of ShowDialog older than 1.6, please note that one parameter for Type 2 has been removed.  In addition, the result is now RETURN-delimited, instead of comma-delimited.  ShowDialog Type 2 can also now have AS MANY Editable Text fields and check boxes as you desire.
  185.            •••••••••••••••••
  186.  
  187.  
  188.  
  189. -- part contents for background part 15
  190. ----- text -----
  191. ShowDialog Type 2 parameters are:
  192.  
  193. ShowDialog 2,<DLOG resource ID>,<first prompt string>,<second prompt string>,<default entry string>
  194. [,<check box BOOLEAN>],[<top coord>,<left coord>]
  195.  
  196. where 2 is the type of the external;
  197. <DLOG resource ID> is the resource ID of the DLOG template;
  198. <first prompt string> consists of the dialog's first text string;
  199. <second prompt string> consists of the dialog's second text string (if you want one);
  200. <default entry string> is a default text string to appear in a text entry field;
  201.  
  202. The last three parameters are OPTIONAL. They are:
  203.  
  204. <check box BOOLEAN> specifies whether your check boxes (if you have any) are initially checked.  This is a comma-delimited list ("TRUE,FALSE,TRUE,TRUE");
  205.  
  206. <top coord>  and <left coord> are used to set the top,left coordinates for placing the dialog.  If these two parameters are omitted, the dialog will be centered within the card window. 
  207.  
  208.  
  209.  
  210. -- part contents for background part 17
  211. ----- text -----
  212. Creating the resources for ShowDialog XCMD Type 2:
  213.  
  214. The requirements for creating DLOG templates for Type 2 of ShowDialog XCMD with ResEdit are:
  215. The visible and goAwayFlag boxes must be unchecked, and the DLOG and associated DITL resources should be made purgeable.
  216.  
  217. You MUST have a default button and it MUST be DITL item #1.  This is because the first item in the item list is always assumed to be the default button.  The Macintosh Toolbox will interpret a press of the Return or Enter key as equivalent to a mouse click in the default button.
  218.  
  219. In your DITL template, your field (of type Static Text) that will contain the first prompt string must contain the placeholder "^0" (don't use the quotes; and that's a zero) and the field that will contain the second text string must contain the placeholder "^1".  If you only want to have one field of static text in your dialog, simply omit the second static text field in the template and pass an empty string in the <second prompt string> parameter. 
  220.  
  221. The field (of type Editable Text) that will contain the default entry string MUST be DITL item #3.
  222.  
  223. CHECK BOXES:
  224. Your check boxes can be ANY DITL item#.  You can have the check boxes initially hilited when the dialog is displayed by passing TRUE (for each check box you want hilited) in the <check box BOOLEAN> parameter.  In other words, if you have 3 check boxes in your dialog, passing "TRUE,FALSE,TRUE" will hilite the first and third check boxes.  If you pass FEWER items in this parameter than there are check boxes, the remaining check boxes will be unhilited.  If you pass MORE items in this parameter than there are check boxes, the remaining items will be ignored.
  225.  
  226. Follow this outline when constructing the DITL resource:
  227. item #1:  OK button (the default)
  228. item #2:  Cancel button
  229. item #3:  Editable Text field (to contain default entry ┬á┬á┬á┬á┬á┬á┬ástring)
  230. remaining items:  Check boxes, additional fields of Editable Text, Static Text fields, icons, and PICT's.
  231.  
  232. The ONLY items that are to be ENABLED are buttons, your check boxes (if you have any), and Editable Text fields.
  233.  
  234. Decide the window type for the dialog:
  235. What you enter into the procID field in the DLOG template will determine how the dialog box looks and whether a window titlebar is displayed.
  236.  
  237. The types that you can choose from are:
  238. 0:   standard window with titlebar
  239. 1:   standard dialog or alert box (no titlebar)
  240. 2:   dialog or alert box with a plain border (no ┬á┬á┬átitlebar)
  241. 3:   dialog or alert box with "shadow" (no titlebar)
  242. 16: accessory window with titlebar (like the ┬á┬á┬ácalculator DA)
  243.  
  244. Please note that having modal dialog boxes with window titlebars is a deviation from Macintosh User Interface guidelines, so you might want to refrain from using these. 
  245.  
  246. The result consists of a return-delimited list.  
  247. If you have only one Editable Text field in your dialog then "the result" will contain the contents of that field.  If you have two or more Editable Text fields, "the result" will contain the contents of the fields in a return-delimited list.  
  248.  
  249. If you have check boxes in your dialog, the first line of the result will be a comma-delimited list reflecting the state of the check boxes at the time the dialog was dismissed.  There will be as many items in the list as there were check boxes in your dialog.  The items will be TRUE for hilited check boxes and FALSE for unhilited ones.
  250.  
  251. If the user clicks the Cancel button "the result" will be empty.
  252.  
  253.